<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
		</script>
		<script>
			$(function(){	
				$(".c").click(function(){
					if($(".c").is(":checked")){
						$(".c1 :checkbox").each(function(i,n){
							//alert(i+","+n)
							$(this).prop("checked",true)
						})
					}else{
						$(".c1 :checkbox").each(function(i,n){
							//alert(i+","+n)
							$(this).prop("checked",false)
						})
					}
				})
				$(".c1 :checkbox").change(function(){
				
					let f=0
					let count=0
					$(".c1 :checkbox").each(function(i,n){
						//alert(i+","+n)
						count++;
						if($(this).prop("checked")){
							f++;
						}else{
							f--;
						}
					})
					if(f==(-count)){
						//alert("全未选中")
						$(".c").prop("checked",false);
					}
					else if(f==count){
						//alert("全选中")
						$(".c").prop("checked",true);
					}else if(f<count){
						//alert("没全选中")
						$(".c").prop("checked",false);
					}
				})
				
			
			})
		</script>
	</head>
	<body>
		<p>全选<input type="checkbox" class="c"><span class="order">排序</span></p>
		<div>
			<p  class="c1"><input type="checkbox"><span>2</span></p>
			<p  class="c1"><input type="checkbox"><span>1</span></p>
			<p  class="c1"><input type="checkbox"><span>4</span></p>
			<p  class="c1"><input type="checkbox"><span>5</span></p>
			<p  class="c1"><input type="checkbox"><span>3</span></p>
		</div>
		
	</body>
</html>
